package ${basePackage}.application.service.${modelNameLowerCamel};

import ${basePackage}.application.dto.EmptyDTO;
import ${basePackage}.application.dto.${modelNameLowerCamel}.UpdateDTO;
import ${basePackage}.application.seek.IService;
import ${basePackage}.application.seek.ServiceAbstract;
import ${basePackage}.domain.${modelNameLowerCamel}.I${modelNameUpperCamel};
import ${basePackage}.domain.${modelNameLowerCamel}.I${modelNameUpperCamel}Repository;
import ${basePackage}.infrastructure.${modelNameLowerCamel}.${modelNameUpperCamel}Repository;

/**
 * Created by ${author} on ${date}.
 * 描述: 更新${modelName}的业务对象
 */

public class UpdateService extends ServiceAbstract<UpdateDTO, EmptyDTO> implements IService<EmptyDTO> {

    /**
     * ${modelName}的仓储对象
     */
    private I${modelNameUpperCamel}Repository i${modelNameUpperCamel}Repository;

    /**
     * 有参构造，获取传入${modelName}参数
     *
     * @param updateDTO ${modelName}参数
      */
    public UpdateService(UpdateDTO updateDTO) {
        super(updateDTO);
    }

    /**
     * 更新${modelName}的业务逻辑
     *
     * @return 空对象
     */
    @Override
    protected EmptyDTO process() {
        try {
            iUnitOfWork.begin();
            i${modelNameUpperCamel}Repository = new ${modelNameUpperCamel}Repository(iUnitOfWork);
            I${modelNameUpperCamel} i${modelNameUpperCamel} = i${modelNameUpperCamel}Repository.get(s.getId());
            if (i${modelNameUpperCamel} == null) {
                throw new RuntimeException();
            }
            //修改属性
            // TODO: ${date}
            //更新修改
            i${modelNameUpperCamel}Repository.update(i${modelNameUpperCamel});
            iUnitOfWork.commit();
            return new EmptyDTO();
        } finally {
            iUnitOfWork.close();
        }
    }
}
